package com.zb.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zb.entity.ZjStoreInboundMaterial;
import com.zb.extend.StoreInboundMaterialExtend;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * 入库物料表 Mapper 接口
 * </p>
 *
 * @author WEN
 * @since 2024-01-12
 */
@Repository
public interface ZjStoreInboundMaterialMapper extends BaseMapper<ZjStoreInboundMaterial> {

    /**
     * 根据入库ID更新入库物料状态
     * @param storeInboundId 入库单ID
     * @param status 入库状态：1-待审核，2-已审核，3-作废/驳回
     */
    void updateStatusById(@Param("storeInboundId") Long storeInboundId, @Param("status") Integer status);

    /**
     * 根据入库ID获取入库物料 & 即时库存
     * @param storeInboundId 入库物料ID
     * @return
     */
    List<StoreInboundMaterialExtend> getMaterialsStockbyStoreInboundId(@Param("storeInboundId") Long storeInboundId);

    /**
     * 根据仓位ID集合分组统计预入库数量
     * @param storePositionIds 仓位ID
     * @return
     */
    List<ZjStoreInboundMaterial> getInStoreQtyGroupByStorePositionIds(@Param("storePositionIds") List<Long> storePositionIds);

    /**
     * 根据商品ID分组统计预入库数量
     * @param storeId 仓库ID
     * @param storePositionId 仓位ID
     * @param goodsIds 商品ID
     * @param goodsSpecIds 商品规格ID
     * @return
     */
    List<ZjStoreInboundMaterial> getInStoreQtyByStoreIdOrStorePositionIdAndGroupByGoodsId(@Param("storeId") Long storeId, @Param("storePositionId") Long storePositionId, @Param("goodsIds") List<Long> goodsIds, @Param("goodsSpecIds") List<Long> goodsSpecIds);

    /**
     * 根据仓库ID分组统计预入库数量
     * @param storeIds 仓库ID
     * @param goodsIds 商品ID
     * @param goodsSpecIds 商品规格ID
     * @return
     */
    List<ZjStoreInboundMaterial> getInStoreQtyByStoreIdGroupByStoreId(@Param("storeIds") List<Long> storeIds, @Param("goodsIds") List<Long> goodsIds, @Param("goodsSpecIds") List<Long> goodsSpecIds);



}
